#!/bin/bash

# while-menu-dialog: a menu driven system information program

DIALOG_CANCEL=1
DIALOG_ESC=255
HEIGHT=0
WIDTH=0

display_result() {
  dialog --title "$1" \
    --no-collapse \
    --msgbox "$result" 0 0
}

while true; do
  exec 3>&1
  selection=$(dialog \
    --backtitle "Arch installer v1.1" \
    --title "Menu" \
    --clear \
    --cancel-label "Exit" \
    --menu "Please select:" $HEIGHT $WIDTH 4 \
    "1" "Inspect" \
    "2" "Update" \
    "3" "Install" \
    "4" "AUR" \
    2>&1 1>&3)
  exit_status=$?
  exec 3>&-
  case $exit_status in
    $DIALOG_CANCEL)
      clear
      echo "Program terminated."
      exit
      ;;
    $DIALOG_ESC)
      clear
      echo "Program aborted." >&2
      exit 1
      ;;
  esac
  case $selection in
    1 )
      vim arch
      ;;
    2 )
      sudo pacman -Syu
      ;;
    3 )
      sudo pacman -Sy abiword acpi alsa-tools alsa-utils arc-gtk-theme bash-completion bc btop cmus curl dunst dvtm ethtool feh firefox flashrom github-cli gnumeric gufw htop inxi jgmenu lxappearance lxappearance-obconf menumaker mpv ncspot neofetch network-manager-applet nextcloud-client obconf openbox papirus-icon-theme pcmanfm picom pulseaudio pulseaudio-alsa python-pip ranger redshift rofi rust scribus scrot slim slim-themes smartmontools sxhkd thunderbird tint2 tlp tlp-rdw ttf-nerd-fonts-symbols ttf-jetbrains-mono ueberzug ufw unzip usbutils util-linux vifm vim volumeicon wget xautolock xdg-user-dirs xdg-user-dirs-gtk xdg-utils xf86-input-synaptics xorg xorg-xinit xorg-xcalc xterm yubioath-desktop zathura-pdf-poppler zsh
      ;;
    4 )
      cd ~/
      git clone https://aur.archlinux.org/yay
      cd yay
      makepkg -si
      yay -S  abook bitwarden epson-inkjet-printer-escpr epsonscan2 epsonscan2-non-free-plugin minitube mullvad-vpn-cli ncspot onlykey steam udiskie transset-df
      ;;
  esac
done
